<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/admin/include/head.htm">
<script type="text/javascript">
	var grid;
	$(function(){
		 grid = $("#maingrid").ligerGrid({
            columns: [
			{display: 'ID', name: 'id', width:30, align: 'left', isAllowHide: false},
			{display: '广告名称', name: 'name', align: 'center', width: 150 },
			{display: '所属广告位', name: 'advertPosition.title', align: 'center', width: 150 },
			{display: '单位名称', name: 'unitName', align: 'center', width: 150 },
			{display: 'LOGO', name: 'realPath', align: 'center', width: 100, 
			 	render: function (row){				
					if (row["realPath"]) {
						var html = '<a href="' + base + row["realPath"] + '" class="imagePreview" target="_blank">查看</a>';
						return html;
					}  											
            	}		
			},
			{display: '开始时间', name: 'startTime', align: 'center', width: 100,
				render:function(row){
					if(row.startTime)
					return row.startTime.split(" ")[0];
				}
			},
			{display: '截止时间', name: 'endTime', align: 'center', width: 100,
				render:function(row){
					if(row.endTime)
					return row.endTime.split(" ")[0];
				}
			},
			{display: '是否开启', name: 'isOpen', align: 'center', width: 100 ,dict:'common'},
			{display: '点击数', name: 'clickNumber', align: 'center', width: 100 },		
			{display: '排序', name: 'priority', align: 'center', width: 100}
			],  pageSize:20, url: 'queryData.jhtml',toolbar: {}, width: '100%', height:'100%', enabledSort: true,
			groupColumnName:'advertPosition.title',groupColumnDisplay:'<span style="color:red;">位置</span>'
        });
		
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		//绑定搜索按钮
		LG.search(grid);
	});
	
	function add(){
		top.f_addTab(null, '新增广告', '${base}/admin/system/advert/add.jhtml?parentMenuNo=advert_list&positionId='+$("#advertPosition").val());
	}
	
	function f_delete() {
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/system/advert/delete.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds) },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请选择行!');
	    }
	}
	  
	//编辑广告
	function edit(){
		var selecteds = grid.getSelecteds();
		if (selecteds.length != 1) { 
			LG.tip('请选择一行记录!'); 
			return; 
		}
		var id = selecteds[0].id;
		if(top.f_isTabItemExist("advert" + id)){
			top.f_switchTab("advert" + id);
		}else{
			top.f_addTab("advert" + id, '修改广告[' + selecteds[0].name + ']', '${base}/admin/system/advert/edit.jhtml?id=' + id);
		}
	};
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">
				<span>
					广告名称：<input id="productName" type="text" name="search_LIKE_name" />
				</span>
				<span>
					所在广告位：
					<@u.select headerKey="" headerValue="全部" listKey="id" listValue="title" id="advertPosition"
						headerButtom="false" list=allAdvertPosition
						name="search_EQ_advertPosition.id" class="{required: true}"/>
				</span>
				<input type="button" class="button" value="搜索" id="search"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">清除本次搜索</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>